<script setup lang="ts">
import { Form } from '@/components/Form'

import { useForm } from '@/hooks/web/useForm'
import { PropType, reactive, watch } from 'vue'
import { FormSchema } from '@/types/form'
import { WorkControlData } from "@/api/manage/work/types";

const props = defineProps({
  currentRow: {
    type: Object as PropType<Nullable<WorkControlData>>,
    default: () => null
  },
  formSchema: {
    type: Array as PropType<FormSchema[]>,
    default: () => []
  }
})

const rules = reactive({
})

const { register, methods, elFormRef } = useForm({
  schema: props.formSchema
})

watch(
  () => props.currentRow,
  (currentRow) => {
    if (!currentRow) return
    const { setValues } = methods
    setValues(currentRow)
  },
  {
    deep: true,
    immediate: true
  }
)

defineExpose({
  elFormRef,
  getFormData: methods.getFormData
})
</script>

<template>
  <Form :rules="rules" @register="register" >
    <template #flow_read-append>GB</template>
    <template #flow_write-append>GB</template>
    <template #max_files-append>个</template>
    <template #max_files_bytes-append>GB</template>
  </Form>
</template>
